import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * Created by Administrator on 2017/1/13.
 */
public class Test02 {
    public static void main(String[] args) {
        System.out.println(FindContinuousSequence(15));
    }

    public static ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
        int nSum = 0;
        Set<ArrayList<Integer>> arrs = new LinkedHashSet<>();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int j = 1; j < sum; j++) {
            for (int i = j; i < sum; i++) {
                nSum += i;
                arr.add(i);
                if (nSum < sum) {
                    continue;
                } else if (nSum == sum) {
                    arrs.add(arr);
                    arr = new ArrayList<>();
                    nSum = 0;
                } else if (nSum > sum) {
                    arr.clear();
                    nSum = 0;
                    break;
                }
            }
        }
        return new ArrayList<>(arrs);
    }

}
